Extract or replace lines of Amiga Basic code
# S3 method for AmigaBasic
[(x, i)# S3 method for AmigaBasic
[(x, i) <- value
# S3 method for AmigaBasic
[[(x, i)
# S3 method for AmigaBasic
[[(x, i) <- value
The extraction method returns an AmigaBasic()
object based in the lines selected with i
.
The replacement method returns an AmigaBasic()
object with the selected lines replaced with value
.
An AmigaBasic
class object from which specific lines
need to be extracted or replaced.
In case of [[', an integer index, representing the line-number of basic code to be selected. In case of
[': a vector
of numeric
indices. This index
is used to select specific lines. Negative values will deselect lines.
A vector
of character
strings or an
AmigaBasic()
class object that is used to replace
the selected indices i
. value
should represent the
same number of lines of code as the selected number of lines.
Pepijn de Vries
Extract or replace specific lines in an AmigaBasic()
-class object.
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
## First generate a few lines of Basic code:
bas <- as.AmigaBasic(c(
"LET a = 1",
"a = a + 1",
"PRINT \"a now equals\";a",
"INPUT \"clear screen (y/n)? \", b$",
"IF UCASE$(b$) = \"Y\" THEN CLS"
))
## Select only lines 4 and 5:
bas[4:5]
## use negative indices to deselect specific lines.
## deselect line 2:
bas[-2]
## replace line 2
bas[2] <- "a = a + 2"
## You can also use AmigaBasic class object as replacement
bas[2] <- as.AmigaBasic("a = a + 3")
## single lines can also be selected with '[['
bas[[2]]
Run the code above in your browser using DataLab